import { IFeidaoAiBrowserComponent } from '@dfeidao/atom-web/interfaces';
import set from '@dfeidao/atom-web/local/set';

// 注释代码的逻辑：选中列表一行数据，让该行的复选框处于选中状态
export default async function a011(fd: IFeidaoAiBrowserComponent, args: { currentTarget: HTMLElement }) {
	const items = fd.data.node.querySelectorAll<HTMLInputElement>('[data-alert_list]');
	const target_node = args.currentTarget.querySelector('[data-feidao-name="list_checkbox"]') as HTMLInputElement;
	// const chackall = fd.data.node.querySelector('[data-feidao-id="checkall"]') as HTMLInputElement;
	const id = target_node.getAttribute('data-feidao-id');
	const code = target_node.getAttribute('data-feidao-usercode');
	set(fd, 'wk_id', id);
	set(fd, 'wk_code', code);
	// if (items.length === 1) {
	// 	chackall.checked = true;
	// } else {
	// 	chackall.checked = false;
	// }
	Array.from(items).forEach((i) => {
		i.classList.remove('bg-c');
		// const list_check = i.querySelector('[data-feidao-name="list_checkbox"]') as HTMLInputElement;
		// list_check.checked = false;
	});
	// target_node.checked = true;
	args.currentTarget.closest('[data-alert_list]').classList.add('bg-c');
}
